package com.aseo.model.entity.hibernate;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

@Entity
@Table(name = "reclamos.recorrido_vehiculo")
public class RecorridoVehiculo implements Serializable {
	
	private static final long serialVersionUID = 7475534559665449098L;

    @SequenceGenerator(name = "reclamos.recorrido_vehiculo_recorrido_vehiculo_id_seq", 
    		           sequenceName = "reclamos.recorrido_vehiculo_recorrido_vehiculo_id_seq")
    @GeneratedValue(generator = "reclamos.recorrido_vehiculo_recorrido_vehiculo_id_seq")
	@Id
    @Basic(optional = false)
    @Column(name = "recorrido_vehiculo_id")
    private Long recorridoVehiculoId;
   
    @NotNull(message = "Debe especificar la fecha del recorrido" )
    @Basic(optional = false)
    @Column(name = "fecha_recorrido")
    private Integer fechaRecorrido;
    
    @Basic(optional = false)
    @Column(name = "fecha_registro")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaRegistro;
    
    @Basic(optional = false)
    @Column(name = "fecha_actualizacion")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fechaActualizacion;
    
    @Basic(optional = false)
    @Column(name = "estado")
    private int estado;
    
    @NotNull(message = "No se a indicado un chofer para el recorrido" )
    @JoinColumn(name = "chofer_id", referencedColumnName = "chofer_id")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Chofer choferId;
    
    @NotNull(message = "No se a indicado un vehiculo para el recorrido" )
    @JoinColumn(name = "vehiculo_id", referencedColumnName = "vehiculo_id")
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Vehiculo vehiculoId;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "recorridoVehiculoId", fetch = FetchType.EAGER)
    private Set<ParadaVehiculo> paradaVehiculoCollection;

    public RecorridoVehiculo() {
    }

    public RecorridoVehiculo(Long recorridoVehiculoId) {
        this.recorridoVehiculoId = recorridoVehiculoId;
    }

    public RecorridoVehiculo(Long recorridoVehiculoId, int fechaRecorrido, Date fechaRegistro, Date fechaActualizacion, int estado) {
        this.recorridoVehiculoId = recorridoVehiculoId;
        this.fechaRecorrido = fechaRecorrido;
        this.fechaRegistro = fechaRegistro;
        this.fechaActualizacion = fechaActualizacion;
        this.estado = estado;
    }

    public Long getRecorridoVehiculoId() {
        return recorridoVehiculoId;
    }

    public void setRecorridoVehiculoId(Long recorridoVehiculoId) {
        this.recorridoVehiculoId = recorridoVehiculoId;
    }

    public Integer getFechaRecorrido() {
        return fechaRecorrido;
    }

    public void setFechaRecorrido(Integer fechaRecorrido) {
        this.fechaRecorrido = fechaRecorrido;
    }

    public Date getFechaRegistro() {
        return fechaRegistro;
    }

    public void setFechaRegistro(Date fechaRegistro) {
        this.fechaRegistro = fechaRegistro;
    }

    public Date getFechaActualizacion() {
        return fechaActualizacion;
    }

    public void setFechaActualizacion(Date fechaActualizacion) {
        this.fechaActualizacion = fechaActualizacion;
    }

    public int getEstado() {
        return estado;
    }

    public void setEstado(int estado) {
        this.estado = estado;
    }

    public Chofer getChoferId() {
        return choferId;
    }

    public void setChoferId(Chofer choferId) {
        this.choferId = choferId;
    }

    public Vehiculo getVehiculoId() {
        return vehiculoId;
    }

    public void setVehiculoId(Vehiculo vehiculoId) {
        this.vehiculoId = vehiculoId;
    }

    public Set<ParadaVehiculo> getParadaVehiculoCollection() {
        return paradaVehiculoCollection;
    }

    public void setParadaVehiculoCollection(Set<ParadaVehiculo> paradaVehiculoCollection) {
        this.paradaVehiculoCollection = paradaVehiculoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (recorridoVehiculoId != null ? recorridoVehiculoId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RecorridoVehiculo)) {
            return false;
        }
        RecorridoVehiculo other = (RecorridoVehiculo) object;
        if ((this.recorridoVehiculoId == null && other.recorridoVehiculoId != null) || (this.recorridoVehiculoId != null && !this.recorridoVehiculoId.equals(other.recorridoVehiculoId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.aseo.model.entity.RecorridoVehiculo[recorridoVehiculoId=" + recorridoVehiculoId + "]";
    }

}
